package com.cn.qtms.dao;//类注释设置模板

import com.cn.qtms.base.dao.BaseDao;
import com.cn.qtms.entity.TmSecAct;
import com.cn.qtms.entity.TmSecKill;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @Name:TmSecKillDao
 * @Description:
 * @Author: zhangyang
 * @Date 2019-12-26 13:25
 **/
@Repository
public interface TmSecKillDao  extends BaseDao<TmSecKill,Long> {
    /**
     * 查询昨天最后一场商品数据
     * @param date
     * @return
     */
    @Query(value = "select *   from  tm_sec_kill where kill_date= :killDate and act_type=4",nativeQuery = true)
    List<TmSecKill> findLastSecKill(@Param("killDate") String date);

    /**
     * 删除三个月前的秒杀数据
     * @param date
     */
    @Modifying
    @Query(value = "delete   from  tm_sec_kill where kill_date <= :killDate",nativeQuery = true)
    void deleteSeckill(@Param("killDate") String date);
}
